Modifying the DXL Wizard code for Traceability

In Module A I have two link modules associated. One link module that 'Satisfies' requirements from another module and another module 'LinksAsOneRequirement' that links multiple objects within Module A for a complete requirement. I did this mainly to reference OLE tables since multiple requirements could potentially reference the same table. Discussing further about 'LinksAsOneRequirement', for example I made a start link from an object and created links to all the OLE tables that it references.

I want to modify the basic wizard code shown below. When it traverses the link to the first depth or in my example to Module A, instead of just displaying the attribute I specified in the wizard I want to check if the object in question 'othero' has any links from the link module 'LinksAsOneRequirement' and if so traverse the links in 'LinksAsOneRequirement' and create a concatenated rich text string before displaying it in the column.

I am not quite sure how to specify this syntax in DXL...if anyone can help I would appreciate it!
 

// DXL generated by DOORS traceability wizard on 05 November 2010.
// Wizard version 2.0, DOORS version 9.3.0.0
pragma runLim, 0
int lines[2] = {0, 0}
void adjustLines(int depth, showAtDepth) {
    int count
    for (count = 0; count < 2; count++) {
        while (lines[depth-1] < lines[count]) {
            if (depth == showAtDepth) displayRich("\\pard " " ")
            lines[depth-1]++
        }
    }
}
void showIn(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    string linkModName = "*"
    for lr in all(o<-linkModName) do {
        otherMod = module (sourceVersion lr)
        if (!null otherMod) {
            if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
                load((sourceVersion lr),false)
            }
        }
    }
    for l in all(o<-linkModName) do {
        otherVersion = sourceVersion l
        otherMod = module(otherVersion)
        if (null otherMod || isDeleted otherMod) continue
        othero = source l
        if (null othero) {
            load(otherVersion,false)
        }
        othero = source l
        if (null othero) continue
        if (isDeleted othero) continue
        int oldLines = lines[depth-1]
        adjustLines(depth, 1)
        bool kick = (doneOne) && (lines[depth-1] == oldLines)
        if (kick) {
            lines[depth-1]++
            if (depth == 1) displayRich("\\pard " " ")
        }
        if (depth < 2) {
            showIn(othero, depth+1)
        }
        doneOne = true
        if (depth == 1) {
            s = probeRichAttr_(othero,"Object Text", false)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)
        }
        lines[depth-1] += 1
    }
    if (depth == 1) {
        ExternalLink extLink
        doneOne = false
        for extLink in o<-"" do {
            if (!doneOne) {
                displayRich("\\pard " "{\\b External Links:}")
                doneOne = true
            }
            s = richText description(extLink)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)
        }
    }
}
showIn(obj,1)

lsand - Fri Nov 12 14:28:55 EST 2010

Re: Modifying the DXL Wizard code for Traceability
llandale - Mon Nov 15 15:14:28 EST 2010

Not much time but here goes. I believe this column should display nothing when the object had no such outgoing 'AsOne' links, but display the current Object Text if indeed it has. Add a boolean "bool TextDumped = false" right number the pragma statement, in the main code. Before the code "s = probeRichAttr_(othero,"Object Text", false)", add the following:
if (!TextDumped)
displayRich(probeRichAttr_(othero,"Object Text", false) "\\pard ")
TextDumped = true

  • Louie

May need an additional space after the \\pard.

Re: Modifying the DXL Wizard code for Traceability
lsand - Mon Nov 15 18:03:05 EST 2010

llandale - Mon Nov 15 15:14:28 EST 2010
Not much time but here goes. I believe this column should display nothing when the object had no such outgoing 'AsOne' links, but display the current Object Text if indeed it has. Add a boolean "bool TextDumped = false" right number the pragma statement, in the main code. Before the code "s = probeRichAttr_(othero,"Object Text", false)", add the following:
if (!TextDumped)
displayRich(probeRichAttr_(othero,"Object Text", false) "\\pard ")
TextDumped = true

  • Louie

May need an additional space after the \\pard.

I've created a function that will go through a specific link module for an object o and concatenate the parent and each child requirement into one requirement text. I verified that the code is returning the correct concatenated complete requirement ..but when I put it into the Wizard's code I get a blank out of it:
 

void DisplayWholeSystemRequirement(Object o, string linkModName)
{
 
    Link currLink;
        
        string completeReq = null;
        string parentReq =  null;
        string childReq = null;
        int numChild = 0;
        //go through every link 
                
        
        for currLink in obj->linkModName do 
        {
                
                Object tarObj = target currLink;
                Object sourceObj = source currLink;
        
                Module m;
                if (null tarObj)
                {
                        //m = read(mn, false);
                        tarObj = target currLink;
                        sourceObj = source currLink;
                }
                 
                if( numChild == 0 )
                {     
                        parentReq = richTextWithOle(sourceObj."Object Text");         
                        childReq = richTextWithOle(tarObj."Object Text");             
                
                        completeReq = parentReq "\\par " childReq
                        
                }
                else 
                {
                        // set the combined string to what it was plus a new line, 
                        //then the new child text
                        childReq = richTextWithOle(tarObj."Object Text");     
                        completeReq = completeReq "\\par " childReq 
                }
                numChild ++
                
        
        }     
 
        displayRich completeReq;
        
}
 
// DXL generated by DOORS traceability wizard on 05 November 2010.
// Wizard version 2.0, DOORS version 9.3.0.0
pragma runLim, 0
 
#include <layout/show.inc>
#include "addins//extensions//EPSAttributesAndModules.inc"
#include "addins//extensions//EPSCommonFunctions.inc"
 
 
int lines[2] = {0, 0}
void adjustLines(int depth, showAtDepth) {
    int count
    for (count = 0; count < 2; count++) {
        while (lines[depth-1] < lines[count]) {
            if (depth == showAtDepth) displayRich("\\pard " " ")
            lines[depth-1]++
        }
    }
}
void showIn(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    string linkModName = "*"
    for lr in all(o<-linkModName) do {
        otherMod = module (sourceVersion lr)
        if (!null otherMod) {
            if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
                load((sourceVersion lr),false)
            }
        }
    }
    for l in all(o<-linkModName) do {
        otherVersion = sourceVersion l
        otherMod = module(otherVersion)
        if (null otherMod || isDeleted otherMod) continue
        othero = source l
        if (null othero) {
            load(otherVersion,false)
        }
        othero = source l
        if (null othero) continue
        if (isDeleted othero) continue
        int oldLines = lines[depth-1]
        adjustLines(depth, 1)
        bool kick = (doneOne) && (lines[depth-1] == oldLines)
        if (kick) {
            lines[depth-1]++
            if (depth == 1) displayRich("\\pard " " ")
        }
        if (depth < 2) {
            showIn(othero, depth+1)
        }
        doneOne = true
        if (depth == 1) 
        {
                DisplayWholeSystemRequirement(othero, _LINKS_AS_ONE_REQUIREMENT); //BLANK?
                
                //s = probeRichAttr_(othero,"Object Text", false)
                //if (s == "") 
                //displayRich("\\pard " " ")
                //else
                //displayRich("\\pard " completeRequirement)
        }
        lines[depth-1] += 1
    }
    if (depth == 1) {
        ExternalLink extLink
        doneOne = false
        for extLink in o<-"" do {
            if (!doneOne) {
                displayRich("\\pard " "{\\b External Links:}")
                doneOne = true
            }
            s = richText description(extLink)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)
        }
    }
}
showIn(obj,1)

Re: Modifying the DXL Wizard code for Traceability
lsand - Mon Nov 15 18:54:24 EST 2010

lsand - Mon Nov 15 18:03:05 EST 2010

I've created a function that will go through a specific link module for an object o and concatenate the parent and each child requirement into one requirement text. I verified that the code is returning the correct concatenated complete requirement ..but when I put it into the Wizard's code I get a blank out of it:
 

void DisplayWholeSystemRequirement(Object o, string linkModName)
{
 
    Link currLink;
        
        string completeReq = null;
        string parentReq =  null;
        string childReq = null;
        int numChild = 0;
        //go through every link 
                
        
        for currLink in obj->linkModName do 
        {
                
                Object tarObj = target currLink;
                Object sourceObj = source currLink;
        
                Module m;
                if (null tarObj)
                {
                        //m = read(mn, false);
                        tarObj = target currLink;
                        sourceObj = source currLink;
                }
                 
                if( numChild == 0 )
                {     
                        parentReq = richTextWithOle(sourceObj."Object Text");         
                        childReq = richTextWithOle(tarObj."Object Text");             
                
                        completeReq = parentReq "\\par " childReq
                        
                }
                else 
                {
                        // set the combined string to what it was plus a new line, 
                        //then the new child text
                        childReq = richTextWithOle(tarObj."Object Text");     
                        completeReq = completeReq "\\par " childReq 
                }
                numChild ++
                
        
        }     
 
        displayRich completeReq;
        
}
 
// DXL generated by DOORS traceability wizard on 05 November 2010.
// Wizard version 2.0, DOORS version 9.3.0.0
pragma runLim, 0
 
#include <layout/show.inc>
#include "addins//extensions//EPSAttributesAndModules.inc"
#include "addins//extensions//EPSCommonFunctions.inc"
 
 
int lines[2] = {0, 0}
void adjustLines(int depth, showAtDepth) {
    int count
    for (count = 0; count < 2; count++) {
        while (lines[depth-1] < lines[count]) {
            if (depth == showAtDepth) displayRich("\\pard " " ")
            lines[depth-1]++
        }
    }
}
void showIn(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    string linkModName = "*"
    for lr in all(o<-linkModName) do {
        otherMod = module (sourceVersion lr)
        if (!null otherMod) {
            if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
                load((sourceVersion lr),false)
            }
        }
    }
    for l in all(o<-linkModName) do {
        otherVersion = sourceVersion l
        otherMod = module(otherVersion)
        if (null otherMod || isDeleted otherMod) continue
        othero = source l
        if (null othero) {
            load(otherVersion,false)
        }
        othero = source l
        if (null othero) continue
        if (isDeleted othero) continue
        int oldLines = lines[depth-1]
        adjustLines(depth, 1)
        bool kick = (doneOne) && (lines[depth-1] == oldLines)
        if (kick) {
            lines[depth-1]++
            if (depth == 1) displayRich("\\pard " " ")
        }
        if (depth < 2) {
            showIn(othero, depth+1)
        }
        doneOne = true
        if (depth == 1) 
        {
                DisplayWholeSystemRequirement(othero, _LINKS_AS_ONE_REQUIREMENT); //BLANK?
                
                //s = probeRichAttr_(othero,"Object Text", false)
                //if (s == "") 
                //displayRich("\\pard " " ")
                //else
                //displayRich("\\pard " completeRequirement)
        }
        lines[depth-1] += 1
    }
    if (depth == 1) {
        ExternalLink extLink
        doneOne = false
        for extLink in o<-"" do {
            if (!doneOne) {
                displayRich("\\pard " "{\\b External Links:}")
                doneOne = true
            }
            s = richText description(extLink)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)
        }
    }
}
showIn(obj,1)

and a correction:
 

DisplayWholeSystemRequirement(Object o, string linkModName)


should be

 

DisplayWholeSystemRequirement(Object obj, string linkModName)


Starting to wonder if my problem has something to do with switching to a different link module from the current link module?

 

Re: Modifying the DXL Wizard code for Traceability
Mathias Mamsch - Tue Nov 16 04:14:09 EST 2010

lsand - Mon Nov 15 18:03:05 EST 2010

I've created a function that will go through a specific link module for an object o and concatenate the parent and each child requirement into one requirement text. I verified that the code is returning the correct concatenated complete requirement ..but when I put it into the Wizard's code I get a blank out of it:
 

void DisplayWholeSystemRequirement(Object o, string linkModName)
{
 
    Link currLink;
        
        string completeReq = null;
        string parentReq =  null;
        string childReq = null;
        int numChild = 0;
        //go through every link 
                
        
        for currLink in obj->linkModName do 
        {
                
                Object tarObj = target currLink;
                Object sourceObj = source currLink;
        
                Module m;
                if (null tarObj)
                {
                        //m = read(mn, false);
                        tarObj = target currLink;
                        sourceObj = source currLink;
                }
                 
                if( numChild == 0 )
                {     
                        parentReq = richTextWithOle(sourceObj."Object Text");         
                        childReq = richTextWithOle(tarObj."Object Text");             
                
                        completeReq = parentReq "\\par " childReq
                        
                }
                else 
                {
                        // set the combined string to what it was plus a new line, 
                        //then the new child text
                        childReq = richTextWithOle(tarObj."Object Text");     
                        completeReq = completeReq "\\par " childReq 
                }
                numChild ++
                
        
        }     
 
        displayRich completeReq;
        
}
 
// DXL generated by DOORS traceability wizard on 05 November 2010.
// Wizard version 2.0, DOORS version 9.3.0.0
pragma runLim, 0
 
#include <layout/show.inc>
#include "addins//extensions//EPSAttributesAndModules.inc"
#include "addins//extensions//EPSCommonFunctions.inc"
 
 
int lines[2] = {0, 0}
void adjustLines(int depth, showAtDepth) {
    int count
    for (count = 0; count < 2; count++) {
        while (lines[depth-1] < lines[count]) {
            if (depth == showAtDepth) displayRich("\\pard " " ")
            lines[depth-1]++
        }
    }
}
void showIn(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    string linkModName = "*"
    for lr in all(o<-linkModName) do {
        otherMod = module (sourceVersion lr)
        if (!null otherMod) {
            if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
                load((sourceVersion lr),false)
            }
        }
    }
    for l in all(o<-linkModName) do {
        otherVersion = sourceVersion l
        otherMod = module(otherVersion)
        if (null otherMod || isDeleted otherMod) continue
        othero = source l
        if (null othero) {
            load(otherVersion,false)
        }
        othero = source l
        if (null othero) continue
        if (isDeleted othero) continue
        int oldLines = lines[depth-1]
        adjustLines(depth, 1)
        bool kick = (doneOne) && (lines[depth-1] == oldLines)
        if (kick) {
            lines[depth-1]++
            if (depth == 1) displayRich("\\pard " " ")
        }
        if (depth < 2) {
            showIn(othero, depth+1)
        }
        doneOne = true
        if (depth == 1) 
        {
                DisplayWholeSystemRequirement(othero, _LINKS_AS_ONE_REQUIREMENT); //BLANK?
                
                //s = probeRichAttr_(othero,"Object Text", false)
                //if (s == "") 
                //displayRich("\\pard " " ")
                //else
                //displayRich("\\pard " completeRequirement)
        }
        lines[depth-1] += 1
    }
    if (depth == 1) {
        ExternalLink extLink
        doneOne = false
        for extLink in o<-"" do {
            if (!doneOne) {
                displayRich("\\pard " "{\\b External Links:}")
                doneOne = true
            }
            s = richText description(extLink)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)
        }
    }
}
showIn(obj,1)

Maybe you should not use "obj" in your function but "o" (the parameter):
 

void DisplayWholeSystemRequirement(Object o, string linkModName)
{ ...
     for currLink in obj->linkModName do  // really? obj?
  ...
}

 


Maybe this helps, Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Modifying the DXL Wizard code for Traceability
lsand - Tue Nov 16 13:18:49 EST 2010

Mathias Mamsch - Tue Nov 16 04:14:09 EST 2010

Maybe you should not use "obj" in your function but "o" (the parameter):
 

void DisplayWholeSystemRequirement(Object o, string linkModName)
{ ...
     for currLink in obj->linkModName do  // really? obj?
  ...
}

 


Maybe this helps, Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

I added the following at the end of the function DisplayWholeSystemRequirement and I no longer get a blank output!
 

if (completeReq == "") 
         displayRich("\\pard " " ")
else
         displayRich("\\pard " completeReq)

Re: Modifying the DXL Wizard code for Traceability
lsand - Wed Nov 17 18:28:13 EST 2010

lsand - Tue Nov 16 13:18:49 EST 2010

I added the following at the end of the function DisplayWholeSystemRequirement and I no longer get a blank output!
 

if (completeReq == "") 
         displayRich("\\pard " " ")
else
         displayRich("\\pard " completeReq)

Fixed the obj to o. Thought my problem was fixed but spoke too soon.

I have a for loop that loops through the links in a particular module ("Satisfies") and inside this for loop I gain access to the source of each link. Once I have the source object I want to proceed with another for loop that will look at every outgoing link (from "LinksAs") of the source object.

the skeleton code looks something like this:

string testString =  "Not Set"
for l in all(o<-"Satisfies") do 
{
     Object sourceOBj = source l
     //not sure if this is needed but set the current folder
     //to the same directory that the "LinksAs" module is in
     for every l in all(sourceOBj -> "LinksAs") do 
     {
        //If there exists an outgoing link, this means that the requiremnts are broken up
 
        //Never gets here not sure why. 
        testString = "Set!!!"
     }
 
}
display testString //outputs "Not Set"

 


Can anyone see a reason why it never makes it into the for loop? If I run the second for loop directly on the module I want to link the requirements it works fine, but inserted into this code it never makes it into the for loop,.

 

Re: Modifying the DXL Wizard code for Traceability
lsand - Wed Nov 17 18:29:45 EST 2010

lsand - Wed Nov 17 18:28:13 EST 2010

Fixed the obj to o. Thought my problem was fixed but spoke too soon.

I have a for loop that loops through the links in a particular module ("Satisfies") and inside this for loop I gain access to the source of each link. Once I have the source object I want to proceed with another for loop that will look at every outgoing link (from "LinksAs") of the source object.

the skeleton code looks something like this:

string testString =  "Not Set"
for l in all(o<-"Satisfies") do 
{
     Object sourceOBj = source l
     //not sure if this is needed but set the current folder
     //to the same directory that the "LinksAs" module is in
     for every l in all(sourceOBj -> "LinksAs") do 
     {
        //If there exists an outgoing link, this means that the requiremnts are broken up
 
        //Never gets here not sure why. 
        testString = "Set!!!"
     }
 
}
display testString //outputs "Not Set"

 


Can anyone see a reason why it never makes it into the for loop? If I run the second for loop directly on the module I want to link the requirements it works fine, but inserted into this code it never makes it into the for loop,.

 

Fixed the obj to o. Thought my problem was fixed but spoke too soon.

I have a for loop that loops through the links in a particular module ("Satisfies") and inside this for loop I gain access to the source of each link. Once I have the source object I want to proceed with another for loop that will look at every outgoing link (from "LinksAs") of the source object.

the skeleton code looks something like this:

string testString =  "Not Set"
for l in all(o<-"Satisfies") do 
{
     Object sourceOBj = source l
     //not sure if this is needed but set the current folder
     //to the same directory that the "LinksAs" module is in
     for every l in all(sourceOBj -> "LinksAs") do 
     {
        //If there exists an outgoing link, this means that the requiremnts are broken up
        //into different objects and this for loop with concatenate the objects into one
        //Never gets here not sure why. 
        testString = "Set!!!"
     }
 
}
display testString //outputs "Not Set"

 


Can anyone see a reason why it never makes it into the for loop? If I extract the second for loop into a function and then apply it directly on the module I want to link the requirements it works fine, but inserted into this code it never makes it into the for loop.

 

Re: Modifying the DXL Wizard code for Traceability
lsand - Wed Nov 17 18:38:27 EST 2010

lsand - Wed Nov 17 18:29:45 EST 2010

Fixed the obj to o. Thought my problem was fixed but spoke too soon.

I have a for loop that loops through the links in a particular module ("Satisfies") and inside this for loop I gain access to the source of each link. Once I have the source object I want to proceed with another for loop that will look at every outgoing link (from "LinksAs") of the source object.

the skeleton code looks something like this:

string testString =  "Not Set"
for l in all(o<-"Satisfies") do 
{
     Object sourceOBj = source l
     //not sure if this is needed but set the current folder
     //to the same directory that the "LinksAs" module is in
     for every l in all(sourceOBj -> "LinksAs") do 
     {
        //If there exists an outgoing link, this means that the requiremnts are broken up
        //into different objects and this for loop with concatenate the objects into one
        //Never gets here not sure why. 
        testString = "Set!!!"
     }
 
}
display testString //outputs "Not Set"

 


Can anyone see a reason why it never makes it into the for loop? If I extract the second for loop into a function and then apply it directly on the module I want to link the requirements it works fine, but inserted into this code it never makes it into the for loop.

 

And I realize that both for loops reference the link l but that is not my problem..

Re: Modifying the DXL Wizard code for Traceability
Mathias Mamsch - Thu Nov 18 03:50:36 EST 2010

lsand - Wed Nov 17 18:38:27 EST 2010
And I realize that both for loops reference the link l but that is not my problem..

You should try making sure that the function gets called with the right objects (the ones with the links). Then you need to have the target modules open before you will be able to iterate over the "Link"s. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Modifying the DXL Wizard code for Traceability
lsand - Thu Nov 18 18:14:39 EST 2010

Mathias Mamsch - Thu Nov 18 03:50:36 EST 2010
You should try making sure that the function gets called with the right objects (the ones with the links). Then you need to have the target modules open before you will be able to iterate over the "Link"s. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

I have the target module open and I am sure that I am getting the right object since I can display the contents of the object before the second for loop...it just seems as if the object doesn't didn't retain any information contained in the link module and therefore is not making it into the loop. Still trying to figure this one out.